/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package creditcardapp.view;

import creditcardapp.model.CreditCardAccount;
import framework.model.Account;
import framework.model.Customer;
import framework.view.AccountTableModel;
import java.util.List;

/**
 *
 * @author ThanhNguyen
 */
public class CreditCardTableModel extends AccountTableModel {

    public CreditCardTableModel() {
        columnNames = new String[]{"Name", "CC Number", "Exp date", "Type", "Balance"};
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        List<Account> accounts = financialCompany.getAccounts();
        Account account = accounts.get(rowIndex);
        Customer customer = account.getCustomer();
        switch (columnIndex) {
            case 0:
                return customer;
            case 1:
                return ((CreditCardAccount) account).getCreditCardNumber();
            case 2:
                return ((CreditCardAccount) account).getExpiredDate();
            case 3:
                return account;
            case 4:
                return account.getCurrentBalance();
            default:
                return null;
        }
    }
}
